package com.glasses.business.adapter;

import android.app.Activity;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.glasses.business.R;
import com.glasses.business.base.MyBaseAdapter;
import com.glasses.business.entity.GlassDetail;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Author：邓勇军
 * English Name：Deng,The Sky Fucker!
 * Email：dandycoder@126.com
 * Date：2017/3/6
 * Version：1.0
 */

public class GlassFrameAdapter extends MyBaseAdapter<GlassDetail, GlassFrameAdapter.ViewHolder> {

    public GlassFrameAdapter(Activity context, List data) {
        super(context, data);
    }

    @Override
    protected ViewHolder getViewHolder() {
        return new ViewHolder(mInflater.inflate(R.layout.item_glass_frame, null));
    }

    @Override
    protected void onBindViewHolder_(ViewHolder holder, int position) {
        if (data != null&&data.size()>0) {
            GlassDetail glassDetail = data.get(position);
            holder.glassFrameImg.setImageURI(glassDetail.getPicture());
            holder.glassFrameContent.setText(glassDetail.getName());
            holder.glassFramePrice.setText("￥"+ glassDetail.getPrice());
        }
    }

    static class ViewHolder extends RecyclerView.ViewHolder {

        @InjectView(R.id.glassFrameImg)
        SimpleDraweeView glassFrameImg;
        @InjectView(R.id.glassFrameContent)
        TextView glassFrameContent;
        @InjectView(R.id.glassFramePrice)
        TextView glassFramePrice;

        ViewHolder(View view) {
            super(view);
            ButterKnife.inject(this, view);
        }
    }
}
